<template>
  <div class="iconslist">
    <swiper class="swiperimg" :options="swiperOption">
      <swiper-slide v-for="(page, index) of pages"  :key="index">
        <div class="icons" v-for="item of page" :key="item.id">
          <img :src="item.imgUrl" alt="">
          <span>{{item.desc}}</span>
        </div>
      </swiper-slide>
    </swiper>
  </div>
</template>

<script>
export default {
  name: 'icons',
  props: {
    iconList: Array
  },
  data: function () {
    return {
      swiperOption: {
        loop: false
      }
    }
  },
  computed: {
    pages () {
      const pages = []
      this.iconList.forEach((item, index) => {
        const page = Math.floor(index / 8)
        if (!pages[page]) {
          pages[page] = []
        }
        pages[page].push(item)
      })
      return pages
    }
  }
}
</script>

<style lang="stylus" scoped>
  @import "~@/assets/style/varible.styl"
.iconslist
  width: 100%
  height: 0
  overflow:hidden
  padding-bottom: 52%
  text-align: center
  /*background: green*/
  .icons
    float: left
    width: 25%
    padding:5px 0
    img
      width: 70%
      height: auto
    span
      display: block
      font-size: .26rem
      color: $coler-black
      text-align: center
</style>
